import Vue from 'vue'
import Vuex from 'vuex'
import getters from "./getters";

Vue.use(Vuex)

const moduleFiles = require.context('./modules', true, /\.js$/);
// eslint-disable-next-line no-unused-vars
const modules = moduleFiles.keys().reduce((modules, modulePath) => {
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1');
  const module = moduleFiles(modulePath);
  modules[moduleName] = module.default;
  return modules;
}, {});

const store = new Vuex.Store({
  modules,
  getters
})

export default store;
